'use strict';

stareal
    .controller("CordeIosController", function ($scope,$interval,$document, $stateParams, $api, $sce, base64, $state, $alert,localStorageService,$timeout,$location, $anchorScroll) {
        var ua = navigator.userAgent.toLowerCase();
        $scope.IP=returnCitySN["cip"];
        $scope.codeId=$stateParams.corderId;
       $("#copy_btn").on('click',function(){
           if(/iphone|ipad|ipod/.test(ua)){
               var copyDOM = document.getElementById("walletCopyInput");  //要复制文字的节点
               var range = document.createRange();
               // 选中需要复制的节点
               range.selectNode(copyDOM);
               // 执行选中元素
               window.getSelection().addRange(range);
               // 执行 copy 操作
               var successful = document.execCommand('copy');
               try {
                   var msg = successful ? '成功' : '失败';
               } catch(err){
               }
               // 移除选中的元素
               window.getSelection().removeAllRanges();
               $api.post("app/channel/h5PvAndIosMsg", {
                   device_msg:ua,
                   ip:$scope.IP,
                   code: $scope.codeId,
                   source:'ios'
               },true).then(function (ret){
                   console.log(ret);
                   //location.href="https://itunes.apple.com/cn/app/%E7%8B%AC%E8%A7%92%E7%A7%80/id1352696908?mt=8";
                  location.href='https://fir.im/chkn';
               });
               // window.location.href="https://itunes.apple.com/cn/app/%E7%8B%AC%E8%A7%92%E7%A7%80/id1352696908?mt=8";
           }else{
               $timeout(function() {
                   $alert.show('请在iphone手机上操作!');
               },0);
           }
       })
    });